#include<bits/stdc++.h>

using namespace std;

int rev(int n) {//n=123
    int m = 0, d;
    while (n > 0) {
        d = n % 10;
        m = m * 10 + d;
        n /= 10;
    }
    return m;
}

int sys(int n) {
    if (n == rev(n))return 1;
    else return 0;
}

int prime(int n) {
    if (n <= 1)return 0;
    for (int i = 2; i <= n - 1; i++) {
        if (n % i == 0) {
            return 0;//return false;
        }
    }
    return 1;
}

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (prime(i) && sys(i))
            cout << i << endl;
    }
    return 0;
}
